package com.training.java.core.homework02;

import java.util.InputMismatchException;
import java.util.Scanner;

public class PrintDayOfWeekArray {

	public static void main(String[] args) {

		Scanner input = new Scanner(System.in);

		String[] stringDaysArray = { "Sunday", "Monday", "Tueday", "Wednesday",
				"Thursday", "Friday", "Saturday" };
		boolean keepTrying;
		int number = 0;

		// Basic validaty of check of the input
		keepTrying = true;
		do {
			try {
				System.out.print("Enter a number between 1 and 7: ");
				number = input.nextInt();
				keepTrying = false;
			} catch (InputMismatchException e) {
				input.next();
				System.out.println("Not a valid number, try again");
				keepTrying = true;
				continue;
			}

			if (number < 1 || number > 7) {
				System.out.println("Not a number between 1 & 7, try again");
				keepTrying = true;
			}
		} while (keepTrying);

		System.out.println(stringDaysArray[number - 1]);
		input.close();
	}
}
